package lab01;

public class Test04 {      //完成求和,用循环
    public static void main(String[] args) {

        int sum = 0;
        //完成for循环求和
        for (int i = 0;i <= 200;i++){
            sum+=i;
        }

        System.out.println("for:"+sum);

        sum = 0;
        //完成while循环求和
        int j = 1;
        while (j <= 100){
            sum+=j;
            j++;
        }

        System.out.println("while:"+sum);

        sum = 0;
        //完成do-while循环求和
        int k = 1;
        do{
            sum+=k;
            k++;

        }while(k <= 100);

        System.out.println("do-while:"+sum);
    }
}
